<?php

use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\AuthController;
use App\Http\Controllers\Admin\BannerController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\ConfigController;
use App\Http\Controllers\Admin\UploadController;
use App\Http\Controllers\Admin\UserController;
use Illuminate\Support\Facades\Route;

//不需要登录就能访问的路由
Route::withoutMiddleware('auth:admin')->group(function () {
    Route::post('login', [AuthController::class,'login'])->name('login');
});
Route::group(['middleware' => ['permission:banner']], function () {
    //轮播图（广告banner）管理
    Route::apiResource('banners', BannerController::class)->except('show');
});

Route::get('homeData',['App\Http\Controllers\Admin\IndexController','homeData']);

//分类管理
Route::apiResource('categories', CategoryController::class)->except(['show']);

//菜单管理
Route::apiResource('menus', \App\Http\Controllers\Admin\Rbac\MenuController::class)->except('show');
//角色管理
Route::get('roles/options',['App\Http\Controllers\Admin\Rbac\RoleController','getOptions']);
//获取角色所拥有的菜单id
Route::get('roleMenuId/{id}',['App\Http\Controllers\Admin\Rbac\RoleController','getRoleMenuId']);
Route::apiResource('roles', \App\Http\Controllers\Admin\Rbac\RoleController::class)->except('show');

//账户（管理员）管理
Route::get('admins/options',['App\Http\Controllers\Admin\AdminController','getOptions']);
Route::apiResource('admins', AdminController::class)->except('show');
//用户管理
Route::apiResource('users', UserController::class);
//获取当前登录用户信息
Route::get('me', [AuthController::class,'me']);
//修改个人资料
Route::post('updateProfile',[AdminController::class,'updateProfile']);
//修改密码
Route::post('updatePassword', [AuthController::class,'updatePassword']);
//退出登录
Route::any('logout', [AuthController::class,'logout']);
//获取配置信息
Route::get('configs', [ConfigController::class,'index']);
//保存配置
Route::post('configs/save', [ConfigController::class,'save']);

//图片上传
Route::post('upload/image',[UploadController::class,'image']);
Route::post('upload/file',[UploadController::class,'file']);
